/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Testing.java
 *
 * Created on Sep 28, 2011, 9:07:23 AM
 */
package Client;

import Interface.*;
//import Server.DeThiImpl;
import java.awt.*;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.plaf.basic.BasicBorders.RadioButtonBorder;
import thaihung.common.Clock;
//import javax.swing.ButtonModel;

/**
 *
 * @author bj
 */
public class Testing extends javax.swing.JFrame {

    ButtonGroup[] buttonGroup = new ButtonGroup[20];
    Clock cl = null;
    Factory factory = null;
    String MaDe = "";
    int soCH = -1;
    int maBaiThi = -1;
    DeThi dt = null;
    BaiThi bt = null;
    ButtonGroup[] group = new ButtonGroup[20];
    Character[] dapAnChon = new Character[20];
    /** Creates new form Testing */
    public Testing() {
        initComponents();
        
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton_LayDeTHi = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField_MaSV = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jTextField_MaDeThi = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel_NgayThi = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jButton_NopBai = new javax.swing.JButton();
        jButton_XemKQ = new javax.swing.JButton();
        jButton_Thoat = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel_ThoiGian = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jPanel_TraLoi = new javax.swing.JPanel();
        jPanel_KetQua = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel_SoCauDung = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel_SoCauSai = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(thaihung.ThaihungApp.class).getContext().getResourceMap(Testing.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setName("Form"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jButton_LayDeTHi.setText(resourceMap.getString("jButton_LayDeTHi.text")); // NOI18N
        jButton_LayDeTHi.setToolTipText(resourceMap.getString("jButton_LayDeTHi.toolTipText")); // NOI18N
        jButton_LayDeTHi.setName("jButton_LayDeTHi"); // NOI18N
        jButton_LayDeTHi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_LayDeTHiActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTextPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jTextPane1.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jTextPane1.border.titleFont"), resourceMap.getColor("jTextPane1.border.titleColor"))); // NOI18N
        jTextPane1.setFont(resourceMap.getFont("jTextPane1.font")); // NOI18N
        jTextPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jTextPane1.setFocusable(false);
        jTextPane1.setName("jTextPane1"); // NOI18N
        jScrollPane1.setViewportView(jTextPane1);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jTextField_MaSV.setEditable(false);
        jTextField_MaSV.setText(resourceMap.getString("jTextField_MaSV.text")); // NOI18N
        jTextField_MaSV.setName("jTextField_MaSV"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jTextField2.setName("jTextField2"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jTextField3.setName("jTextField3"); // NOI18N

        jTextField_MaDeThi.setText(resourceMap.getString("jTextField_MaDeThi.text")); // NOI18N
        jTextField_MaDeThi.setName("jTextField_MaDeThi"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        jLabel_NgayThi.setText(resourceMap.getString("jLabel_NgayThi.text")); // NOI18N
        jLabel_NgayThi.setName("jLabel_NgayThi"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(15, 15, 15)
                        .add(jLabel1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextField_MaSV))
                    .add(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel2)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(36, 36, 36)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel3)
                    .add(jLabel4))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
                    .add(jTextField_MaDeThi, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jLabel6))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel19)
                        .add(18, 18, 18)
                        .add(jLabel_NgayThi)))
                .add(29, 29, 29))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextField_MaSV, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1)
                    .add(jLabel3)
                    .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel19)
                    .add(jLabel_NgayThi))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4)
                    .add(jTextField_MaDeThi, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel5)
                    .add(jLabel6))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setName("jPanel3"); // NOI18N

        jButton_NopBai.setText(resourceMap.getString("jButton_NopBai.text")); // NOI18N
        jButton_NopBai.setName("jButton_NopBai"); // NOI18N
        jButton_NopBai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_NopBaiActionPerformed(evt);
            }
        });
        jPanel3.add(jButton_NopBai);

        jButton_XemKQ.setText(resourceMap.getString("jButton_XemKQ.text")); // NOI18N
        jButton_XemKQ.setName("jButton_XemKQ"); // NOI18N
        jButton_XemKQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_XemKQActionPerformed(evt);
            }
        });
        jPanel3.add(jButton_XemKQ);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(thaihung.ThaihungApp.class).getContext().getActionMap(Testing.class, this);
        jButton_Thoat.setAction(actionMap.get("quit")); // NOI18N
        jButton_Thoat.setText(resourceMap.getString("jButton_Thoat.text")); // NOI18N
        jButton_Thoat.setName("jButton_Thoat"); // NOI18N
        jPanel3.add(jButton_Thoat);

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setToolTipText(resourceMap.getString("jLabel14.toolTipText")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jLabel15.setIcon(resourceMap.getIcon("jLabel15.icon")); // NOI18N
        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setToolTipText(resourceMap.getString("jLabel17.toolTipText")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel_ThoiGian.setFont(resourceMap.getFont("jLabel_ThoiGian.font")); // NOI18N
        jLabel_ThoiGian.setForeground(resourceMap.getColor("jLabel_ThoiGian.foreground")); // NOI18N
        jLabel_ThoiGian.setText(resourceMap.getString("jLabel_ThoiGian.text")); // NOI18N
        jLabel_ThoiGian.setName("jLabel_ThoiGian"); // NOI18N

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jPanel_TraLoi.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel_TraLoi.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel_TraLoi.border.titleFont"), resourceMap.getColor("jPanel_TraLoi.border.titleColor"))); // NOI18N
        jPanel_TraLoi.setAutoscrolls(true);
        jPanel_TraLoi.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel_TraLoi.setName("jPanel_TraLoi"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel_TraLoiLayout = new org.jdesktop.layout.GroupLayout(jPanel_TraLoi);
        jPanel_TraLoi.setLayout(jPanel_TraLoiLayout);
        jPanel_TraLoiLayout.setHorizontalGroup(
            jPanel_TraLoiLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 262, Short.MAX_VALUE)
        );
        jPanel_TraLoiLayout.setVerticalGroup(
            jPanel_TraLoiLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 263, Short.MAX_VALUE)
        );

        jScrollPane2.setViewportView(jPanel_TraLoi);

        jPanel_KetQua.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel_KetQua.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel_KetQua.border.titleFont"), resourceMap.getColor("jPanel_KetQua.border.titleColor"))); // NOI18N
        jPanel_KetQua.setName("jPanel_KetQua"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel_SoCauDung.setText(resourceMap.getString("jLabel_SoCauDung.text")); // NOI18N
        jLabel_SoCauDung.setName("jLabel_SoCauDung"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel_SoCauSai.setText(resourceMap.getString("jLabel_SoCauSai.text")); // NOI18N
        jLabel_SoCauSai.setName("jLabel_SoCauSai"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel_KetQuaLayout = new org.jdesktop.layout.GroupLayout(jPanel_KetQua);
        jPanel_KetQua.setLayout(jPanel_KetQuaLayout);
        jPanel_KetQuaLayout.setHorizontalGroup(
            jPanel_KetQuaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel_KetQuaLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel_KetQuaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel_KetQuaLayout.createSequentialGroup()
                        .add(jLabel7)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel_SoCauDung))
                    .add(jPanel_KetQuaLayout.createSequentialGroup()
                        .add(jLabel9)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel_SoCauSai)))
                .addContainerGap(67, Short.MAX_VALUE))
        );
        jPanel_KetQuaLayout.setVerticalGroup(
            jPanel_KetQuaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel_KetQuaLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel_KetQuaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(jLabel_SoCauDung))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel_KetQuaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel9)
                    .add(jLabel_SoCauSai))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createSequentialGroup()
                        .add(14, 14, 14)
                        .add(jLabel14)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel15)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel16)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel_ThoiGian)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jLabel17)
                        .add(48, 48, 48))
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                .add(jButton_LayDeTHi)
                                .add(jScrollPane2, 0, 0, Short.MAX_VALUE)
                                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, Short.MAX_VALUE))
                            .add(jPanel_KetQua, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(jLabel15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel14)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel16)
                        .add(jLabel_ThoiGian)
                        .add(jLabel17)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jButton_LayDeTHi)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 291, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel_KetQua, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 507, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        getAccessibleContext().setAccessibleDescription(resourceMap.getString("Form.AccessibleContext.accessibleDescription")); // NOI18N

        pack();
    }// </editor-fold>//GEN-END:initComponents
//nvld@gmail.com
    private void jButton_LayDeTHiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_LayDeTHiActionPerformed
        // TODO add your handling code here:
        MaDe = jTextField_MaDeThi.getText();
        jButton_NopBai.setEnabled(true);
        jButton_LayDeTHi.setEnabled(false);
        try
        {           
            jTextPane1.setText(dt.LayDeThi(MaDe));
            HienThiThoiGian();
            HienThiDSCauTraLoi();
        }  
        catch(Exception ex)
        {
            javax.swing.JOptionPane.showMessageDialog(this, ex.toString());
        }       
    }//GEN-LAST:event_jButton_LayDeTHiActionPerformed

    private void jButton_NopBaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_NopBaiActionPerformed
      
//      if(javax.swing.JOptionPane.showMessageDialog()
      int ok = JOptionPane.showConfirmDialog(this,"Bạn có chắc chắn nộp bài ?","Xác Nhận",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
      if(ok==0)
      {
          NgatThoiGian(); 
          jButton_NopBai.setEnabled(false);
          jButton_XemKQ.setEnabled(true);
          jPanel_TraLoi.setEnabled(false);
          for(int i = 0 ; i<soCH ; i++)
          {
              Enumeration x = group[i].getElements();
              int j;
              for( j = 0 ; j<4 ; j++)
              {
                  AbstractButton r = (AbstractButton)x.nextElement();
                  if(r.isSelected())
                  {
                      switch (j) {
                          case 0:
                              dapAnChon[i] = new Character('A');
                              break;
                          case 1:
                              dapAnChon[i] = new Character('B');
                              break;
                          case 2:
                              dapAnChon[i] = new Character('C');
                              break;
                          case 3:
                              dapAnChon[i] = new Character('D');
                              break;
                      }
                      break;                  
                  }
              }
              if(j==4)
                  dapAnChon[i] = new Character('n');
          }

          try {
              maBaiThi = bt.NopBai(jTextField_MaSV.getText(), jTextField_MaDeThi.getText(), jLabel_NgayThi.getText(),dapAnChon);
          } catch (RemoteException ex) {
                javax.swing.JOptionPane.showMessageDialog(this, ex.toString());
          } catch (SQLException ex) {
                javax.swing.JOptionPane.showMessageDialog(this, ex.toString());
          }
      }
    }//GEN-LAST:event_jButton_NopBaiActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        //An bang ket qua
        jPanel_KetQua.setVisible(false);
        jButton_NopBai.setEnabled(false);
        jButton_XemKQ.setEnabled(false);
        
        Date toDay = new Date(System.currentTimeMillis());
        SimpleDateFormat dayFormat = new SimpleDateFormat("MM/dd/yyy");
        String todayS = dayFormat.format(toDay.getTime());
        jLabel_NgayThi.setText(todayS);
        
        
        //Hien thi thoi gian lam bai
        try
        {
            factory = (Factory)Naming.lookup("rmi://127.0.0.1:1308/Factory");
            dt = factory.createDeThi();
            bt = factory.createBaiThi();
            soCH = dt.SoLuongCH(jTextField_MaDeThi.getText());
            int time = dt.GetTGLamBai(jTextField_MaDeThi.getText());
            jLabel6.setText("" + time);
        }
        catch(Exception e)
        {
            System.out.println(e);
            javax.swing.JOptionPane.showMessageDialog(this, "Lỗi kết nối tới server !");
        }
    }//GEN-LAST:event_formWindowOpened

    private void jButton_XemKQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_XemKQActionPerformed
        // TODO add your handling code here
        try
        {
            jPanel_KetQua.setVisible(true);
            int soCauDung = bt.XemKetQua(maBaiThi,jTextField_MaDeThi.getText());
            jLabel_SoCauDung.setText(String.valueOf(soCauDung));
            jLabel_SoCauSai.setText(String.valueOf(soCH - soCauDung));        
        }
        catch (RemoteException ex) {
            javax.swing.JOptionPane.showMessageDialog(this, ex.toString());
        } catch (SQLException ex) {
                javax.swing.JOptionPane.showMessageDialog(this, ex.toString());
        }
    }//GEN-LAST:event_jButton_XemKQActionPerformed
    
    private void HienThiThoiGian() throws SQLException {
        cl = new Clock(jLabel_ThoiGian,jTextField_MaDeThi);
        cl.start();
    }
    
    private void NgatThoiGian() {
        cl.stop();
        //cl.reset();
        jLabel_ThoiGian.setText("00:00");
    }
     
    private void HienThiDSCauTraLoi(){

        GridBagLayout layout = new GridBagLayout();
        jPanel_TraLoi.setLayout(layout);
        GridBagConstraints constraints = new GridBagConstraints(); 
        //constraints.fill = GridBagConstraints.BOTH;
        constraints.anchor = GridBagConstraints.ABOVE_BASELINE;
        for(int i = 2 ; i<=5 ; i++)
        {
             constraints.gridy = 1;
             constraints.gridx = i;
             constraints.gridheight = 1;
             constraints.gridwidth = 1;
             Label lb = new Label();
             switch(i)
             {
                 case 2 :
                     lb.setText("A");
                     break;
                 case 3 :
                     lb.setText("B");
                     break;
                 case 4 :
                     lb.setText("C");
                     break;
                 case 5 :
                     lb.setText("D");
                     break;
             }
             layout.setConstraints(lb, constraints);
             jPanel_TraLoi.add(lb);
        }
         
        for(int i = 0 ; i<soCH ; i++)
        {
            constraints.gridy = i+2;
            constraints.gridx = 1;
            constraints.gridheight = 1;
            constraints.gridwidth = 1;
            Label lb = new Label("Câu " + (i+1) + " : ");
            layout.setConstraints(lb, constraints);
            jPanel_TraLoi.add(lb);
            
            group[i] = new ButtonGroup();
            JRadioButton[] cau = new JRadioButton[4];
            
            for(int j = 2 ; j<6 ; j++)
            {
                constraints.gridy = i+2;
                constraints.gridx = j;
                constraints.gridheight = 1;
                constraints.gridwidth = 1;
                cau[j-2] = new JRadioButton();
                layout.setConstraints(cau[j-2], constraints);
               
                group[i].add(cau[j-2]);  
                jPanel_TraLoi.add(cau[j-2]);
            }
        }  
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Testing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Testing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Testing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Testing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Testing().setVisible(true);
            }
        });
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    javax.swing.JButton jButton_LayDeTHi;
    javax.swing.JButton jButton_NopBai;
    javax.swing.JButton jButton_Thoat;
    javax.swing.JButton jButton_XemKQ;
    javax.swing.JLabel jLabel1;
    javax.swing.JLabel jLabel14;
    javax.swing.JLabel jLabel15;
    javax.swing.JLabel jLabel16;
    javax.swing.JLabel jLabel17;
    javax.swing.JLabel jLabel19;
    javax.swing.JLabel jLabel2;
    javax.swing.JLabel jLabel3;
    javax.swing.JLabel jLabel4;
    javax.swing.JLabel jLabel5;
    javax.swing.JLabel jLabel6;
    javax.swing.JLabel jLabel7;
    javax.swing.JLabel jLabel9;
    javax.swing.JLabel jLabel_NgayThi;
    javax.swing.JLabel jLabel_SoCauDung;
    javax.swing.JLabel jLabel_SoCauSai;
    javax.swing.JLabel jLabel_ThoiGian;
    javax.swing.JPanel jPanel2;
    javax.swing.JPanel jPanel3;
    javax.swing.JPanel jPanel_KetQua;
    javax.swing.JPanel jPanel_TraLoi;
    javax.swing.JScrollPane jScrollPane1;
    javax.swing.JScrollPane jScrollPane2;
    javax.swing.JTextField jTextField2;
    javax.swing.JTextField jTextField3;
    javax.swing.JTextField jTextField_MaDeThi;
    javax.swing.JTextField jTextField_MaSV;
    javax.swing.JTextPane jTextPane1;
    // End of variables declaration//GEN-END:variables


    

    
}
